package com.alks.function.controller.procurement;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.dto.procurement.PcPackTypeDto;
import com.alks.function.data.request.procurement.PackagMaterialRequest;
import com.alks.function.data.request.procurement.PcPackStyleTypeMtlRequest;
import com.alks.function.data.request.procurement.SdMaterialRequest;
import com.alks.function.service.procurement.BrandMaterialDefinitionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@ApiRestController("/BrandMaterialDefinition")
@Slf4j
@Api(tags = {"采购部-品牌包材定义","采购部-物料资料建档"})
@RoleCheck(prgIds = {"150106"},methodName = "getBrandTypeList")
public class BrandMaterialDefinitionController {

    @Autowired
    private BrandMaterialDefinitionService brandMaterialDefinitionService;

    /*品牌*/
    @WebLogger
    @GetMapping("/getBrandTypeList")
    @ApiOperation(value = "品牌-回显",tags = "采购部-品牌包材定义")
    public ResponseInfo getBrandTypeList(@RequestParam(required = false) String style){
        return brandMaterialDefinitionService.getBrandTypeList(style);
    }

//    @WebLogger
//    @PostMapping("/addBrand")
//    @ApiOperation(value = "品牌-添加",tags = "采购部-品牌包材定义")
//    public ResponseInfo addBrand(@RequestParam String style){
//        return brandMaterialDefinitionService.addBrand(style);
//    }

    /*品牌明细*/
    @WebLogger
    @GetMapping("/getBrandMaterialList")
    @ApiOperation(value = "品牌明细：查询",tags = "采购部-品牌包材定义")
    public ResponseInfo getBrandMaterialList(@RequestParam(required = false) String style){
        return brandMaterialDefinitionService.getBrandMaterialListByStyle(style);
    }

    @WebLogger
    @PostMapping("/addBrandMaterial")
    @ApiOperation(value = "品牌明细：增加",tags = "采购部-品牌包材定义")
    public ResponseInfo addBrandMaterial(@RequestParam String style){
        return brandMaterialDefinitionService.addBrandMaterial(style);
    }

    @WebLogger
    @PostMapping("/deleteBrandMaterial")
    @ApiOperation(value = "品牌明细：删除",tags = "采购部-品牌包材定义")
    public ResponseInfo deleteBrandMaterial(@RequestParam String style){
        return brandMaterialDefinitionService.deleteBrandMaterial(style);
    }

    /*包材分类明细*/
    @WebLogger
    @GetMapping("/getPackageMaterialByStyle")
    @ApiOperation(value = "包材分类明细：查询",tags = "采购部-品牌包材定义")
    public ResponseInfo getPackageMaterialByStyle(@RequestParam String style){
        return brandMaterialDefinitionService.getPackageMaterialByStyle(style);
    }
    @WebLogger
    @PostMapping("/getPackagMaterialList")
    @ApiOperation(value = "选择包材分类:查询", tags = "采购部-品牌包材定义")
    public ResponseInfo getPackagMaterialList(@RequestParam String style) {
        return brandMaterialDefinitionService.getPackagMaterialList(style);
    }
    @WebLogger
    @PostMapping("/addPackagMaterial")
    @ApiOperation(value = "包材分类明细：批量增加=选择分类", tags = "采购部-品牌包材定义")
    public ResponseInfo addPackagMaterial(@RequestParam String style, @RequestBody List<PackagMaterialRequest> request) {
        return brandMaterialDefinitionService.addPackagMaterial(request,style);
    }

    @WebLogger
    @PostMapping("/deletePackagMaterial")
    @ApiOperation(value = "包材分类明细：删除（待补充）",tags = "采购部-品牌包材定义")
    public ResponseInfo deletePackagMaterial(@RequestBody PackagMaterialRequest request, @RequestParam String style){
        return brandMaterialDefinitionService.deletePackagMaterial(request,style);
    }

    @WebLogger
    @PostMapping("/updatePackagMaterial")
    @ApiOperation(value = "包材分类明细：批量编辑",tags = "采购部-品牌包材定义")
    public ResponseInfo updatePackagMaterial(@RequestBody List<PackagMaterialRequest> request,@RequestParam String style){
        return brandMaterialDefinitionService.updatePackagMaterial(request,style);
    }

    /*材料明细*/
    @WebLogger
    @PostMapping("/getMaterialDetailList")
    @ApiOperation(value = "材料明细：查询",tags = "采购部-品牌包材定义")
    public ResponseInfo getMaterialDetailList(@RequestParam String style, @RequestBody PackagMaterialRequest request){
        return brandMaterialDefinitionService.getMaterialList(style,request);
    }

    @WebLogger
    @PostMapping("/deleteMaterialDetail")
    @ApiOperation(value = "材料明细：删除",tags = "采购部-品牌包材定义")
    public ResponseInfo deleteMaterialDetail(@RequestParam String style, @RequestBody PackagMaterialRequest request, @RequestParam String mtlNo ){
        return brandMaterialDefinitionService.deleteMaterial(style,request,mtlNo);
    }

    @WebLogger
    @PostMapping("/addMaterialDetail")
    @ApiOperation(value = "材料明细：新增",tags = "采购部-品牌包材定义")
    public ResponseInfo addMaterialDetail(@RequestBody PcPackStyleTypeMtlRequest request ){
        return brandMaterialDefinitionService.addMaterialDetail(request);
    }

    @WebLogger
    @PostMapping("/addBatchMaterialDetail")
    @ApiOperation(value = "选择包材材料中挑到装箱方式后确认:添加到材料明细",tags = "采购部-品牌包材定义")
    public ResponseInfo addBatchMaterialDetail(@RequestBody List<PcPackStyleTypeMtlRequest> request ){
        return brandMaterialDefinitionService.addBatchMaterialDetail(request);
    }

    @WebLogger
    @PostMapping("/updateMaterialDetail")
    @ApiOperation(value = "材料明细：编辑（用量（比））",tags = "采购部-品牌包材定义")
    public ResponseInfo updateMaterialDetail(@RequestBody PcPackStyleTypeMtlRequest request ){
        return brandMaterialDefinitionService.updateMaterialDetail(request);
    }

    /*其他*/
    /*定义装箱方式*/
    @WebLogger
    @PostMapping("/addBoxingStyle")
    @ApiOperation(value = "定义装箱方式:定义",tags = "采购部-品牌包材定义")
    public ResponseInfo addBoxingStyle(@RequestBody List<PcPackTypeDto> request){
        return brandMaterialDefinitionService.addBoxingStyle(request);
    }

    @WebLogger
    @GetMapping("/addBoxingStyle")
    @ApiOperation(value = "定义装箱方式：查询",tags = "采购部-品牌包材定义")
    public ResponseInfo getBoxingStyle(){
        return brandMaterialDefinitionService.getBoxingStyle();
    }

    /*物料建档*/
    @WebLogger
    @PostMapping("/getBrandMaterialList")
    @ApiOperation(value = "物料资料建档：查询",tags = "采购部-物料资料建档")
    public ResponseInfo getMaterialDataFilingList(@RequestBody SdMaterialRequest request){
        return brandMaterialDefinitionService.getMaterialDataFilingList(request);
    }

    @WebLogger
    @PostMapping("/makeSdMaterial")
    @ApiOperation(value = "物料资料建档：生成物料编码",tags = "采购部-物料资料建档")
    public ResponseInfo makeSdMaterial(@RequestBody SdMaterialRequest request){
        return brandMaterialDefinitionService.makeSdMaterial(request);
    }

    @WebLogger
    @PostMapping("/addSdMaterial")
    @ApiOperation(value = "物料资料建档：增加",tags = "采购部-物料资料建档")
    public ResponseInfo addSdMaterial(@RequestBody SdMaterialRequest request){
        return brandMaterialDefinitionService.addSdMaterial(request);
    }

    @WebLogger
    @PostMapping("/updateSdMaterial")
    @ApiOperation(value = "物料资料建档：编辑",tags = "采购部-物料资料建档")
    public ResponseInfo updateSdMaterial(@RequestBody SdMaterialRequest request){
        return brandMaterialDefinitionService.updateSdMaterial(request);
    }

    @WebLogger
    @PostMapping("/deleteMaterialDataFiling")
    @ApiOperation(value = "物料资料建档：删除",tags = "采购部-物料资料建档")
    public ResponseInfo deleteMaterialDataFiling(@RequestParam String mtlNo){
        return brandMaterialDefinitionService.deleteMaterialDataFiling(mtlNo);
    }

    /*删除*/
    @WebLogger
    @GetMapping("/deleteAllBrandMaterial")
    @ApiOperation(value = "整个品牌删除",tags = "采购部-品牌包材定义")
    public ResponseInfo deleteAllBrandMaterial(@RequestParam String style ){
        return brandMaterialDefinitionService.deleteAllBrandMaterial(style);
    }

}
